#include "UnitTest++.h"
#include "FileUtils.h"
#include <unistd.h>
#include <stdlib.h>

TEST(ShouldCreateAllDirectoriesGivenAPath)
{
    const char* path = "resources/proof/chinga/Tu/Madre/";
    createDirectoriesFromPath(path);
    CHECK(isDirectory(path));
    system("rm -r resources/proof");
}

TEST(ShouldReturnTheFileNamesOfADirectory)
{
    std::vector<std::string> paths;
    navigateDirectory("resources/TestDirectoryFileHeader", paths);
    std::string expected = "resources/TestDirectoryFileHeader/";
    std::string expected2 = "resources/TestDirectoryFileHeader/test";

    CHECK_EQUAL(expected2, paths.at(1));
    CHECK_EQUAL(expected, paths.at(0));
}

TEST(ShouldReturnTheFileNamesSizeOfADirectory)
{
    std::vector<std::string> paths;
    navigateDirectory("resources/TestDirectory", paths);

    CHECK_EQUAL(3, paths.size());
}

TEST(ShouldGiveTheSimpleName)
{
    const char* path = "resources/TestDirectory";
    const char* simpleName = getSimpleName(path);
    const char* excepted = "TestDirectory";
    CHECK_EQUAL(excepted, simpleName);
}

TEST(ShouldGiveTheSimpleNameWithoutASlash)
{
    const char* path = "resources/TestDirectory/";
    const char* simpleName = getSimpleName(path);
    const char* excepted = "TestDirectory/";
    CHECK_EQUAL(excepted, simpleName);
}

TEST(ShouldBack)
{
    std::string path = "/home/jorge/Documents";
    std::string result = backToRelativePath(path);
    CHECK_EQUAL("/home/jorge", result);
}